<div><%= @results.size %> results for "<%= @search_text %>"</div>

<% unless @results.empty? %>
  <table>
    <tr>
      <th/>
      <th><%= link_to_remote "Core Concept Name", :update => "search_results", :loading => "loading_image('search_results');", :url => sort_results_url("name") %><%= sort_arrow "name" %></th>
      <th><%= link_to_remote "Local Key", :update => "search_results", :loading => "loading_image('search_results');", :url => sort_results_url("local_key") %><%= sort_arrow "local_key" %></th>
      <% @results[0].attrs.each do |attr| %>
        <th><%= link_to_remote attr.name, :update => "search_results", :loading => "loading_image('search_results');", :url => sort_results_url(attr.name) %><%= sort_arrow attr.name %></th>
      <% end %>
    </tr>
    <% for concept in @results do %>
      <tr class="<%= cycle "even", "odd" %>">
        <td id="map_<%= @selected_concept.id %>_<%= concept.id %>">
          <% if @selected_concept.mappings.include? concept %>
            &#10003;
          <% else %>
            <%#= link_to_remote "Map", :url => {:controller => "concepts", :action => "new_map"} %>
            <%= button_to_function "Map", "map_to_concept(#{concept.id})" %>
          <% end %>
        </td>
        <td><%= highlight concept.name, @search_text %></td>
        <td><%= highlight concept.local_key, @search_text %></td>
        <% concept.attrs.each do |attr| %>
          <td><%= @include_attrs ? highlight(attr.value, @search_text) : attr.value %></td>
        <% end %>
      </tr>
    <% end %>
  </table>
<% end %>